#ifndef FILE_ContentFile_HPP
#define FILE_ContentFile_HPP

#include <string>
#include <fstream>

#include "../System.hpp"

#include "DataFile.hpp"

namespace se{
///////////////////////////////////////////////////////////////////////////////
///	\brief Allow to access a ContentFile (.scf).
///
/// It is created with a string giving the path to the .scf file.
/// Once the ContentFile is opened, you can get 
///////////////////////////////////////////////////////////////////////////////
class ContentFile{
	DISALLOW_COPY_AND_ASSIGN(ContentFile);
	public:
		ContentFile();
		ContentFile(const char* filePath);
		void Open(const char* filePath);
		void Close();
		~ContentFile();//auto close
		
		bool IsOpened() const;
		DataFile& Get(DataFile& target, uint32_t contentRef);
		
	private:
		bool m_opened;
		std::ifstream m_file;
		char m_filetype; //either 'd' for debug, or 'R' for release Raw, or'r' for release with filenames (in coming). might be more
		uint32_t m_blockSize;//for release only, the number of spaces needed to reach the next memory block
		uint64_t m_filesize;
		//functions
		DataFile& GetFromDebug(DataFile& target, uint32_t contentRef);
		DataFile& GetFromRawRelease(DataFile& target, uint32_t contentRef);
		//DataFile& GetFromRelease(DataFile& target, uint32_t contentRef);
		void loadDataFileFromFile(DataFile& target, char* filename, uint32_t contentRef = 0);
		void testFileTypeIsContentFile(const char* filePath);
};


}//namespace se

#endif // FILE_ContentFile_HPP
